Previous Book Contents Book Index Next

Inside Macintosh: AppleScript Language Guide / Part 2 - AppleScript Language Reference
Chapter 7 - Control Statements / Repeat Statements


Repeat Until

The Repeat Until form of the Repeat statement repeats a group of statements until a particular condition, specified in a Boolean expression, is met.

SYNTAX
repeat until Boolean
   [ statement ]...
end [ repeat ]
where

Boolean is an expression whose value is true or false. The statements in the loop are repeated until Boolean becomes true. If Boolean is true when entering the loop, the statements in the loop are not executed.

statement is any AppleScript statement.

EXAMPLE
This example numbers the paragraphs of a document with the Repeat Until form of the Repeat statement.

tell document "List"   set numParagraphs to (count paragraphs)
   set paragraphNum to 1
   repeat until paragraphNum > numParagraphs
      set paragraph paragraphNum to  (paragraphNum as string) & " " ÿ         & paragraph paragraphNum
      set paragraphNum to paragraphNum + 1
   end repeat
end tell

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996